import fs from 'fs'

const p1 = new Promise((resolve, reject) => {
    fs.readFile('./txt/a.txt', 'utf8', (err, data) => {
        if (err == null) {
            resolve(data)
        } else {
            reject(err)
        }
    })
})

p1.then(res => { console.log(res) }, err => { console.log('文件读取错误' + err.message) })